﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MemoryIndexNet.DataStructures;

namespace MemoryIndexNet.Indexes
{
    public class UniqueComparableIndex<TKey, T> :  KeyedIndex<TKey, T>
        where TKey: IComparable<TKey>
    {
        IBinarySearchTree<TKey, T> _index = ImmutableAvlTree<TKey, T>.Empty;

        public void Add(T value)
        {
            var key = KeyExtractor(value);
            _index = _index.Add(key, value);
        }

        public UniqueComparableIndex(Func<T, TKey> keyExtractor)
            : base(keyExtractor)
        {
        }

        public IEnumerable<T> GetBetween(ComparableKeyBetweenConstraint<TKey> constraints)
        {
            var from = _index.Search(constraints.Min.Border);
            var to = _index.Search(constraints.Max.Border);

            throw new NotImplementedException();
        }
    }
}
